/********************************************************************
	file name:	hy_if_then_else.h
	created:	2012/03/26 20:10
	author:		supercaco@sina.com
	purpose:	
*********************************************************************/
#ifndef _HY_IF_THEN_ELSE_H_
#define _HY_IF_THEN_ELSE_H_

namespace hy
{
	/**
	* @struct if_then_else
	*
	* @brief Compile-time selection of type based on a boolean value.
	*
	* This primary template selects the second or third argument based
	* on the value of the boolean first argument.
	*
	* Usage example:
	*
	* \code
	*
	*   template <typename T>
	*   class Foo
	*   {
	*   public:
	*     // Set "TheType" to be the larger of "T" and  "int".
	*     typedef typename if_then_else<(sizeof (T) > sizeof (int)),
	*                                   T,
	*                                   int>::result_type TheType;
	*   };
	*
	* \endcode
	*
	* @note This merely a forward declaration since we really only care
	*       about the partial specializations below.
	*/
	template <bool C, typename Ta, typename Tb>
	struct if_then_else;

	/**
	* @struct if_then_else
	*
	* @brief Select of type @a Ta if boolean value is @c true.
	*
	* This partial specialization selects the type @a Ta if the boolean
	* first argument is @c true.
	*/
	template <typename Ta, typename Tb>
	struct if_then_else<true, Ta, Tb>
	{
		typedef Ta result_type;
	};

	/**
	* @struct if_then_else
	*
	* @brief Select of type @a Tb if boolean value is @c false.
	*
	* This partial specialization selects the type @a Tb if the boolean
	* first argument is @c false.
	*/
	template <typename Ta, typename Tb>
	struct if_then_else<false, Ta, Tb>
	{
		typedef Tb result_type;
	};

} //namespace hy

#endif //_hy_IF_THEN_ELSE_H_